import Vue from 'vue'
import VueI18n from 'vue-i18n'
import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang
import enLocale from './base_en'
import zhLocale from './base_zh'
import enMenuLocale from './menu_en'
import zhMenuLocale from './menu_zh'
import enSysLocale from './sys_en'
import zhSysLocale from './sys_zh'
import enAntLocale from './ant_en'
import zhAntLocale from './ant_zh'
import { getStore } from '@/util/store'
Vue.use(VueI18n)

const messages = {
  en: {
    ...enLocale,
    ...enMenuLocale,
    ...enSysLocale,
    ...enAntLocale,
    ...elementEnLocale
  },
  zh: {
    ...zhLocale,
    ...zhMenuLocale,
    ...zhSysLocale,
    ...zhAntLocale,
    ...elementZhLocale
  }
}

const i18n = new VueI18n({
  locale: getStore({ name: 'language' }) || 'zh',
  messages
})

export default i18n